home *** CD-ROM | disk | FTP | other *** search
/ Amiga Game-Power / Amiga Game-Power.iso / pd mix ii / access / thai / main.c < prev    next >
C/C++ Source or Header  |  1994-05-20  |  2KB  |  103 lines

  1.  
  2. #include "quiz.h"
  3.  
  4. APTR IntuitionBase;
  5. APTR GfxBase;
  6.  
  7. extern APTR OpenLibrary ();
  8. extern struct IntuiMessage *GetMsg ();
  9. extern struct Window *OpenWindow ();
  10.  
  11.  
  12. static struct NewWindow nw = {
  13.     0 , 0 , 640 , 200 , -1 , -1 ,
  14.     GADGETUP | CLOSEWINDOW ,
  15.     WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG | SMART_REFRESH | NOCAREREFRESH 
  16.     | ACTIVATE ,
  17.     NULL , NULL , (UBYTE *) "Thai Quizer V1.0" , NULL , NULL ,
  18.     640 , 200 , 640 , 200 , WBENCHSCREEN
  19. };
  20.  
  21.  
  22. main ()
  23. {
  24.     GfxBase = OpenLibrary ( "graphics.library" , 0L );
  25.     if ( GfxBase == NULL ) {
  26.         exit ( 1 );
  27.     }
  28.     IntuitionBase = OpenLibrary ( "intuition.library" , 0L );
  29.     if ( IntuitionBase == NULL ) {
  30.         CloseLibrary ( GfxBase );
  31.         exit ( 1 );
  32.     }
  33.     window = OpenWindow ( &nw );
  34.     if ( window == NULL ) {
  35.         CloseLibrary ( GfxBase );
  36.         CloseLibrary ( IntuitionBase );
  37.         exit ( 1 );
  38.     }
  39.     if ( ! open_thai_font () ) {
  40.         CloseLibrary ( GfxBase );
  41.         CloseLibrary ( IntuitionBase );
  42.         CloseWindow ( window );
  43.         exit ( 1 );
  44.     }
  45.     if ( ! init_speech () ) {
  46.         close_thai_font ();
  47.         CloseLibrary ( GfxBase );
  48.         CloseLibrary ( IntuitionBase );
  49.         CloseWindow ( window );
  50.         exit ( 1 );
  51.     }
  52.     init_thai_keyboard ();
  53.     init_globals ();
  54.     if ( load_phrases () ) {
  55.  
  56.         do_commands ();
  57.  
  58.     }
  59.     else
  60.         puts ( "Failed to load phrases" );
  61.     unload_phrases ();
  62.     close_speech ();
  63.     close_thai_font ();
  64.     CloseWindow ( window );
  65.     CloseLibrary ( GfxBase );
  66.     CloseLibrary ( IntuitionBase );
  67. }
  68.  
  69.  
  70. do_commands ()
  71. {
  72.     struct IntuiMessage *msg;
  73.     int quit;
  74.     struct Gadget *gadget;
  75.  
  76.  
  77.     quit = FALSE;
  78.     while ( ! quit ) {
  79.         WaitPort ( window->UserPort );
  80.         while ( msg = GetMsg ( window->UserPort ) ) {
  81.  
  82.             switch ( msg->Class ) {
  83.  
  84.             case CLOSEWINDOW :
  85.                 quit = TRUE;
  86.                 ReplyMsg ( msg );
  87.                 break;
  88.  
  89.             case GADGETUP :
  90.                 gadget = (struct Gadget *) msg->IAddress;
  91.                 ReplyMsg ( msg );
  92.                 do_gadget ( gadget );
  93.                 break;
  94.  
  95.             default :
  96.                 ReplyMsg ( msg );
  97.                 break;
  98.             }
  99.         }
  100.     }
  101. }
  102.  
  103.